package com.itboye.ihomebank.util;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.wheelview.WheelView;

import android.app.Activity;
import android.app.ActionBar.LayoutParams;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.PopupWindow;
import android.widget.TextView;
/**
 * 户型（弹出框）
 *
 */
public class HuXingPopupWindow extends PopupWindow {
	
	private View cameraMenuView;
	WheelView year;
	
	
	public HuXingPopupWindow(Activity context, OnClickListener itemOnclick) {
		
		super(context);
		
		LayoutInflater layoutInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		cameraMenuView = layoutInflater.inflate(R.layout.popup_huxing,null);
		
		TextView huxing_cancel = (TextView) cameraMenuView.findViewById(R.id.huxing_cancel);
		TextView huxing_ok = (TextView) cameraMenuView.findViewById(R.id.huxing_ok);
		TextView huxing_title = (TextView) cameraMenuView.findViewById(R.id.huxing_title);
		huxing_title.setText("户型选择");
		huxing_cancel.setOnClickListener(itemOnclick);
		huxing_ok.setOnClickListener(itemOnclick);
		
		
		this.setContentView(cameraMenuView);
		this.setWidth(LayoutParams.FILL_PARENT);
		this.setHeight(LayoutParams.WRAP_CONTENT);
		this.setFocusable(true);
//		this.setAnimationStyle(R.style.AnimBottom);
		ColorDrawable dw = new ColorDrawable(0xb000000);
		this.setBackgroundDrawable(dw);
		
		cameraMenuView.setOnTouchListener(new OnTouchListener() {

			@Override
			public boolean onTouch(View v, MotionEvent event) {
				int height = cameraMenuView.findViewById(R.id.huxing_layout)
						.getTop();
				int y = (int) event.getY();
				if (event.getAction() == MotionEvent.ACTION_UP) {
					if (y < height) {
						dismiss();
					}
				}

				return true;
			}
		});
		
	}
	

}
